//
//  ListTableViewCell.m
//  KeleAppProject
//
//  Created by Cen Zhou on 2018/1/16.
//  Copyright © 2018年 Cen Zhou. All rights reserved.
//

#import "ListTableViewCell.h"

@interface ListTableViewCell()

@property (nonatomic, strong) UIView *displayView;
@end


@implementation ListTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style
              reuseIdentifier:(NSString *)reuseIdentifier
                         type:(NSString *)type
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        NSString *temType = ([type isEqualToString:@""] || type == nil) ? @"default":type;
        [self loadSubviewsOnListCellWithType:temType];
    }
    return self;
}

- (void)loadSubviewsOnListCellWithType:(NSString *)type{
 
    UIView *displayView =  [[UIView alloc]init];
    displayView.backgroundColor = [UIColor blackColor];
    self.displayView = displayView;
    [self.contentView addSubview:displayView];
    [displayView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.width.mas_equalTo(130*WIDTH);
        make.height.mas_equalTo(90*HEIGHT);
        make.left.equalTo(self.contentView).offset(15*WIDTH);
    }];
    
    UILabel *titleLb = [[UILabel alloc]init];
    titleLb.text = @"小姐的骄傲克难奋进地方看见你就开了房大家哈播放九点吧发放";
    titleLb.numberOfLines = 2;
    titleLb.font = [UIFont fontWithName:@"PingFangSC-Regular" size:15*WIDTH];
    titleLb.textColor = KLColor_B6;
    [self.contentView addSubview:titleLb];
    [titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(displayView);
        make.left.equalTo(displayView.mas_right).offset(10*WIDTH);
        make.width.mas_equalTo(205*WIDTH);
        make.height.mas_equalTo(44*HEIGHT);
    }];
    
    UILabel *timeLb = [[UILabel alloc]init];
    timeLb.text = @"2017-09-05 15:56";
    timeLb.font = [UIFont fontWithName:@"PingFangSC-Regular" size:12*WIDTH];
    timeLb.textColor = KLColor_B8;
    [self.contentView addSubview:timeLb];
    [timeLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(titleLb);
        make.top.equalTo(titleLb.mas_bottom).offset(2);
        make.width.equalTo(titleLb);
    }];
    
    if ([type isEqualToString:@"default"]) {
     
        UILabel *source = [[UILabel alloc]init];
        source.text = @"社会大魔王";
        source.textColor = KLColor_B8;
        source.font = [UIFont fontWithName:@"PingFangSC-Regular" size:12*WIDTH];
        [self.contentView addSubview:source];
        [source mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(timeLb);
            make.bottom.equalTo(displayView);
        }];
        UILabel *playNum = [[UILabel alloc]init];
        playNum.text = @"播放2万次";
        playNum.textColor = KLColor_B8;
        playNum.font = [UIFont fontWithName:@"PingFangSC-Regular" size:12*WIDTH];
        [self.contentView addSubview:playNum];
        [playNum mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(source);
            make.left.equalTo(source.mas_right).offset(8*WIDTH);
        }];

    }
    
    
   
    
    if ([type isEqualToString:@"waitCheck"]) {
        UIButton *editBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [editBtn setTitle:@"编辑" forState:UIControlStateNormal];
        [editBtn setTitleColor:KLColor_B1 forState:UIControlStateNormal];
        editBtn.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:14*WIDTH];
        [self.contentView addSubview:editBtn];
        [editBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(displayView);
            make.right.equalTo(self.contentView).offset(-73*WIDTH);
            make.width.mas_equalTo(30*WIDTH);
            make.height.mas_equalTo(20*HEIGHT);
        }];
        
        UIButton *deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [deleteBtn setTitle:@"删除" forState:UIControlStateNormal];
        [deleteBtn setTitleColor:KLColor_A1 forState:UIControlStateNormal];
        deleteBtn.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:14*WIDTH];
        [self.contentView addSubview:deleteBtn];
        [deleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(displayView);
            make.right.equalTo(self.contentView).offset(-15*WIDTH);
            make.width.mas_equalTo(30*WIDTH);
            make.height.mas_equalTo(20*HEIGHT);
        }];
    }
    
    if ([type isEqualToString:@"denyCheck"]) {
        UIButton *deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [deleteBtn setTitle:@"删除" forState:UIControlStateNormal];
        [deleteBtn setTitleColor:KLColor_A1 forState:UIControlStateNormal];
        deleteBtn.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:14*WIDTH];
        [self.contentView addSubview:deleteBtn];
        [deleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(displayView);
            make.right.equalTo(self.contentView).offset(-15*WIDTH);
            make.width.mas_equalTo(30*WIDTH);
            make.height.mas_equalTo(20*HEIGHT);
        }];
    }
    
    
    UIView *lineView = [[UIView alloc]init];
    lineView.backgroundColor = KLColor_B3;
    [self.contentView addSubview:lineView];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.right.equalTo(self.contentView);
        make.left.equalTo(displayView);
        make.height.mas_equalTo(1);
    }];
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
